#ifndef __HELLOWORLD_SCENE_H__
#define __HELLOWORLD_SCENE_H__

#include "cocos2d.h"

#include "SimpleAudioEngine.h"

USING_NS_CC;

class Mech;
class HeroMech;

typedef enum
{
	kEndReasonWin,
	kEndReasonLose
} EndReason;

class HelloWorld : public cocos2d::CCLayer
{
public:
	HelloWorld();
	virtual ~HelloWorld();

    virtual bool init();  
    static cocos2d::CCScene* scene();
    void menuCloseCallback(CCObject* pSender);
    LAYER_CREATE_FUNC(HelloWorld);
	void update(float dt);

	float tileMapHeight();
	float tileMapWidth();
	bool isValidPosition(CCPoint position);
	bool isValidTileCoord(CCPoint tileCoord);
	CCPoint tileCoordForPosition(CCPoint position);
	CCPoint positionForTileCoord(CCPoint tileCoord);
	void setViewpointCenter(CCPoint position);

	virtual void ccTouchesBegan(CCSet *pTouches, CCEvent *pEvent);
	virtual void ccTouchesMoved(CCSet *pTouches, CCEvent *pEvent);
	virtual void ccTouchesEnded(CCSet *pTouches, CCEvent *pEvent);

	bool isProp(std::string prop,CCPoint tileCoord,CCTMXLayer *layer);
	bool isPropAtPos(std::string prop,CCPoint position,CCTMXLayer *layer);
	bool isWallAtTileCoord(CCPoint tileCoord);
	bool isWallAtPosition(CCPoint position);
	bool isWallAtRect(CCRect rect);

	CCSpriteBatchNode *batchNode;
	HeroMech *mech;
	CCArray *enemyTanks;

	void restartTapped(CCObject *sender);
	void endScene(EndReason endReason);
private:
	CCTMXTiledMap * _tileMap;
	CCTMXLayer * _bgLayer;

	CCParticleSystemQuad * _explosion;
	CCParticleSystemQuad * _explosion2;
	bool _gameOver;
	CCSprite * _exit;
};

#endif  // __HELLOWORLD_SCENE_H__